//
//  ST_UnlockSweetShipViewController.swift
//  btvideo
//
//  Created by mac on 2020/7/16.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit

class ST_UnlockSweetShipViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.addSubview(scan_animate_view)
        scan_animate_view.snp.makeConstraints { (make) in
            make.width.height.equalTo(150.0/375.0*ScreenWidth)
            make.centerX.equalToSuperview()
            make.centerY.equalToSuperview().offset(iPhoneXSeries ? -80 : -10)
        }
        
        self.view.addSubview(scan_gift_image_view)
        scan_gift_image_view.snp.makeConstraints { (make) in
            make.width.height.equalTo(116/375.0*ScreenWidth)
            make.center.equalTo(scan_animate_view)
        }
        
        self.view.addSubview(content_label)
        content_label.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(scan_gift_image_view.snp.bottom).offset(21)
            make.height.equalTo(20)
        }
        
        
        
        scan_animate_view.play()
        
        main_thread_execute(afterDelay: 2) {
            self.goback_previous_controller(animated: false)
        }
        
    }
    
    var url = ""{
        didSet{
            scan_gift_image_view.pin_setImage(from: url.url, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
        }
    }
    
    var name = ""{
        didSet{
            content_label.text = "恭喜！你们获得了“\(name)”亲密徽章！"
        }
    }
    
    fileprivate lazy var scan_gift_image_view:UIImageView = {
       
        let control = UIImageView()
        control.contentMode = .scaleAspectFill
        control.cornerRadius = 116/2.0
        return control
    }()
    
    fileprivate lazy var scan_animate_view:LOTAnimationView = {
        
        let path = Bundle.main.path(forResource: "receiveGiftBack", ofType: "json")!
        
        let control = LOTAnimationView.init(filePath: path)
        
        control.contentMode = UIView.ContentMode.scaleAspectFill
        
        control.loopAnimation = true
        
        return control
    }()

    

    fileprivate lazy var content_label:UILabel = {
        let control = UILabel.init()
//        control.text = "恭喜！你们获得了“恋爱秘钥”亲密徽章！"
        control.textColor = UIColor.white
        control.textAlignment = .center
        control.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.semibold)
        return control
    }()
}
